import { Controller, Get, Post, Delete, Swagger, FollowHandler } from '../../infrastructure/controller-helper';
import { Request, Response, NextFunction } from 'express';
const { chain, map } = require('pointfree-fantasy');
const { pipe, view, lensPath, apply, tap, lensProp, props, pick, ifElse, prop, head, path } = require('ramda');
const { merge } = require('lodash/fp');
const Task = require('data.task');
import { captcha, register, verifyLogin, getBackPassword, appointmentClass } from './auth.service';
import { mergeRequestParametersMiddleware } from '../../config/middlewares';

@Controller('/auth')
export class LoginController {
    @Post('/sendcaptcha', mergeRequestParametersMiddleware)
    public sendCaptcha(req: Request, res: Response) {
        let run = pipe(
            prop('parameters'),
            captcha,
        );
        return run(req);
    }

    @Post('/login', mergeRequestParametersMiddleware)
    public login(req: Request, res: Response) {
        let run = pipe(
            prop('parameters'),
            verifyLogin,
        );
        return run(req);
    }

    @Post('/register', mergeRequestParametersMiddleware)
    public register(req: Request, res: Response) {
        let run = pipe(
            prop('parameters'),
            register
        );
        return run(req);
    }

    @Post('/getbackpassword', mergeRequestParametersMiddleware)
    public getBackPassword(req: Request, res: Response) {
        let run = pipe(
            prop('parameters'),
            getBackPassword
        );
        return run(req);
    }

    @Post('/appointment', mergeRequestParametersMiddleware)
    public appointmentClass(req: Request, res: Response) {
        let run = pipe(
            prop('parameters'),
            appointmentClass
        );
        return run(req);
    }
}